import { Component, OnInit } from '@angular/core';
import { PlatformLocation } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
@Component({
  selector: 'app-tabbar',
  templateUrl: './tabbar.component.html',
  styleUrls: ['./tabbar.component.css']
})
export class TabbarComponent implements OnInit {
  [x: string]: any;

  // 初始变量userPic/shopcarPic/storePic负责改变图片
   // tslint:disable-next-line: no-inferrable-types
  public userPic: boolean = false;
   // tslint:disable-next-line: no-inferrable-types
  public shopcarPic: boolean = false;
  // tslint:disable-next-line: no-inferrable-types
  public storePic: boolean = true;

  // 获取当前url
  public locationUrl: any;

  // 用于默认路由跳转第一次 判断
  // tslint:disable-next-line: no-inferrable-types
  public firstIn: boolean = false;

  constructor(private route: ActivatedRoute, private location: PlatformLocation) {
    // 获取当前的url
    for (const i in this.location) {
      if (i === 'location') {
        this.locationUrl = this.location[i].href;
        break;
      }
    }
    // 如果当前是...将对应图片进行改变
    if (this.locationUrl === 'http://localhost:4200/tabbar/store') {
        // 默认进去设置背景
        this.firstIn = true;
    }
   }

  ngOnInit() { }
  changeStorePic() {
    this.userPic = false;
    this.shopcarPic = false;
    this.storePic = true;
    // console.log(this.locationUrl);
  }
  changeShopcarPic() {
    this.userPic = false;
    this.shopcarPic = true;
    this.storePic = false;
    console.log(this.storePic);
  }
  changeUserPic() {
    this.userPic = true;
    this.shopcarPic = false;
    this.storePic = false;
    // console.log(this.locationUrl);
  }
}
